package com.goods.business.controller;

import com.goods.business.service.OutStockService;
import com.goods.common.model.business.OutStock;
import com.goods.common.response.ResponseBean;
import com.goods.common.vo.business.InStockVO;
import com.goods.common.vo.business.OutStockVO;
import com.goods.common.vo.system.PageVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * @Author jiaoyanlin
 * @Date 2021/11/10 17:12
 * @Description OutStockController
 * 出库
 */
@RestController
@RequestMapping("/business/outStock")
public class OutStockController {
    @Autowired
    private OutStockService outStockService;
    @GetMapping("/findOutStockList")
    public ResponseBean<PageVO<OutStockVO>> findOutStockList(@RequestParam Map<String,Object> map){
        PageVO<OutStockVO> pageVO =  outStockService.findOutStockList(map);
        return ResponseBean.success(pageVO);
    }
    @PostMapping("/addOutStock")
    public ResponseBean addOutStock(@RequestBody OutStockVO outStockVO){
       Boolean flag = outStockService.addOutStock(outStockVO);
         if (flag)
              return ResponseBean.success();
         else
             return ResponseBean.error(false);
    }


             /*      返回的数据：
                    this.detailTable = res.data.itemVOS;
                    this.detailTotal = res.data.total;
                    this.consumer=res.data.consumerVO;
                    this.pStatus=res.data.status;
                    this.dialogVisible = true;*/
    @GetMapping("/detail/{id}")
    public ResponseBean<Map<String, Object>> detail(@PathVariable Integer id,
                                                              @RequestParam(value = "pageNum",defaultValue = "1")Integer pageNum){
        Map<String, Object> map = outStockService.detail(id, pageNum);
        return ResponseBean.success(map);

    }
}
